<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

class CoreInfoBox {
	var $_head;
	var $_content;
	
	//constructor
	function CoreInfoBox($head = '', $content = '') {
		$this->_head = $head;
		$this->_content = $content;
	}
	
	//methods
	function setHead($head) {
		$this->_head = $head;
	}
	
	function getHead() {
		return $this->_head;
	}
	
	function setContent($content) {
		$this->_content = $content;
	}
	
	function getItem() {
		return $this->_content;
	}
	
	function output() {
		return $this->_format();
	}
	
	function display() {
		echo $this->output();
	}
	
	//style
	function setStyle($style) {
		$this->_style = $style;
	}
	
	function getStyle($style) {
		return $this->_style;
	}
	
	function setHeadStyle($style) {
		$this->_headstle = $style;
	}
	
	function getHeadStyle() {
		return $this->_headstyle;
	}
	
	function setContentStyle($style) {
		$this->_contentstyle = $style;
	}
	
	function getItemStyle() {
		return $this->_contentstyle;
	}
	
	//
	function _format_header() {
		$html = '';
		$html .= '<div class="infoBoxHeading' . (isset($this->_headstyle)? ' ' . $this->_headstyle : '') . '">';
		$html .= $this->_head;
		$html .= '</div>';
		
		return $html;
	}
	
	function _format_content() {
		$html = '';
		$html .= '<div class="infoBoxContent' . (isset($this->_contentstyle)? ' ' . $this->_contentstyle : '') . '">';
		if( is_array($this->_content) ) {
			foreach($this->_content as $item) {
				$html .= '<div class="infoItem">' . $item . '</div>';
			}
		} else {
			$html .= '<div class="infoItem">' . $this->_content . '</div>';
		}
		$html .= '</div>';
		
		return $html;
	}
	
	function _format() {
		$html = '';
		$html .= '<div class="infoBox' . (isset($this->_contentstyle)? ' ' . $this->_contentstyle : '') . '">';
		$html .= $this->_format_header();
		$html .= $this->_format_content();
		$html .= '</div>';
		
		return $html;
	}
}
//
?>